package com.google.code.fluentjoiner;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

public class FutureToValueFunction<T> implements SerializableFunction<Future<T>, T>
{
    @Override
    public T apply(final Future<T> future)
    {
        try
        {
            return future.get();
        }
        catch (final InterruptedException interruptedException)
        {
            throw new RuntimeException("InterruptedException thrown.", interruptedException);
        }
        catch (final ExecutionException executionException)
        {
            throw new RuntimeException("ExecutionException thrown.", executionException);
        }
    }
}